/* This file is just here so that you try what the SymCe can do.*/
#include "Multitree.h"
#include <stdio.h>
int main(){
	Multitree * x = treevariable("x");
	Multitree * a = treevariable("a");
	Multitree * b = treevariable("b");
	Multitree * c = treevariable("c");
	Multitree * d = treevariable("d");
	Multitree * e = treevariable("e");
	Multitree * f = treevariable("f");

	/* cos x */
	Multitree * x2 = treecos(x);

	/*third derivative of cos x*/
	puts(treetostring(treediff(treediff(treediff(x2, x), x),x)));
	/* diff of tan x + sin x */
	puts(treetostring(treediff(treeplus(treetan(x), treesin(x)), x)));
	/* (a+b)/x*(c-d)/(e-f) expanded */
	puts(treetostring(treeexpand(treediv(treemul(
							treediv(treeplus(a, b), x),
							treeminus(c, d)),
						treeminus(e, f)))
			 ));
	/* 0*a - 0*b +c */
	puts(treetostring(treeplus(treeminus(treemul(a, inttotree(0)), treemul(b, inttotree(0))), c)));
	/* (a+b)^-3 expanded */
	puts(treetostring(treeexpand(treepow(treeplus(a, b), inttotree(-3)))));
	/* x-x */
	puts(treetostring(treeminus(x, x)));
	/* x+x */
	puts(treetostring(treeplus(x, x)));
	/* 0*x */
	puts(treetostring(treemul(inttotree(0), x)));
	/* x^2 + x*x - x - 2*x + x*x - 3*x^2 + 3*x */
	puts(treetostring(treeplus(treeminus(treeplus(treeminus(treeminus(treeplus(treepow(x, inttotree(2)), treemul(x, x)), x), treemul(inttotree(2), x)), treemul(x, x)), treemul(inttotree(3), treepow(x, inttotree(2)))), treemul(inttotree(3), x))));
	/* first derivative of ln(x) */
	puts(treetostring(treediff(treeln(x), x)));
	/* ten terms of taylor polynomial of cos(x) with center in zero */
	puts(treetostring(treetaylor(x2, inttotree(0), 10, x)));
	/* same as previous, but with center in one */
	puts(treetostring(treetaylor(x2, inttotree(1), 10, x)));

	/* Loop that differentiates cos(x) indefinitely - to see, if how much memory it consumes*/
/*	while(1){
		a = treediff(x2, x);
		x2 = a;
		puts(treetostring(x2));
	}*/

	/* x^2 */
	puts(treetostring(treediff(treepow(x, inttotree(2)), x)));
	/* (a+b)^4 */
	puts(treetostring(treeexpand(treepow(treeplus(a, b), inttotree(4)))));
	/* 1/0 */
	puts(treetostring(treediv(inttotree(1), inttotree(0))));
	return 0;
}

